#include<iostream>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_set>
#include<bits/stdc++.h>
#define fi first
#define se second
#define SIZE(x) ((int)x.size())
#define out(x) cerr<<#x<<" = "<<(x)<<endl;
#define MP(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
#define VI vector<int>
#define VVI vector< vector<int> >
#define VC vector<char>
#define PI pair<int,int>
#define PL pair<ll,ll>
#define EPS 0.0000001


inline int lson(int x){return x<<1;}
inline int rson(int x){return (x<<1)|1;}

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

template<typename T> 
inline void read(T &x){
	x=0;T f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

#define MOD 998244353

void extgcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x=1;y=0;
		return;
	}
	extgcd(b,a%b,y,x);y-=x*(a/b);
}

struct node{
	ll x,y;
};
node xy[2005];
ll n,k;
//P4781拉格朗日插值
int main(){
    #ifdef BUG
    freopen("a.in","r",stdin);
    #endif
	n=read();
	k=read();
	for(int i=0;i<n;i++){
		xy[i].x=read();
		xy[i].y=read();
	}
	ll res=0;
	ll tmp,tmp1,tmp2,x,y;
	for(int i=0;i<n;i++){
		tmp1=1;tmp2=1;tmp=1;
		for(int j=0;j<n;j++){
			if(j==i)continue;
			tmp1=(tmp1*(k-xy[j].x))%MOD;
			tmp2=(tmp2*(xy[i].x-xy[j].x))%MOD;
		}
		tmp2=((tmp2%MOD)+MOD)%MOD;
		tmp1=((tmp1%MOD)+MOD)%MOD;
		extgcd(tmp2,MOD,x,y);
		x=((x%MOD)+MOD)%MOD;
		tmp=(xy[i].y*x)%MOD;
		tmp=(tmp*tmp1)%MOD;
		res=(res+tmp)%MOD;
	}
	cout<<res<<endl;
}